package inhert继承;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lenovo
 * Date: 2022-06-27
 * Time: 9:59
 */
//父类 抽取的子类的共性
class Animal{
 public String name = "动物";
 public int age = 0;

    public void eat(){
        System.out.println(this.name+"正在吃饭");
    }
}
//子类Dog继承父类Animal
class Dog extends Animal{
    //子类Dog自己特有的属性和方法
    public String name = "小白";
    public int age = 5;
    public int weight;
    public void bark(){
        System.out.println(this.name+"正在汪汪汪！");
    }
    public void eat(String name ){
        System.out.println(this.name+"正在吃狗粮");
    }
    public void fun(){
        this.eat();
        this.eat("小白");
       this.bark();
    }
}
//子类猫继承父类Animal
class Cat extends Animal{
    //子类Cat自己特有的属性和方法
    public String kind;
    public void miaomiao(){
        System.out.println(this.name+"正在喵喵喵！");
    }
}
public class Test {
    public static void main(String[] args) {
        Dog dog = new Dog();
        dog.fun();
    }
}
